<?php
/**
 * Created by PhpStorm.
 * User: fenfen
 * Date: 2016/12/20
 * Time: 16:01
 */

namespace bc\model;
use bc\ar\MActiveRecord;

class OrderAddressModel extends MActiveRecord
{

    /**
     * address表
     */
    public static function tableName()
    {
        return '{{%order_address}}';
    }

    /*
     * 根据用户id获取用户的地址列表
     * */
    public function getAddlistFromUserId($id)
    {
        if(empty($id))
            return array();
        $this->autoId = 'uid';
        $useList = $this->getList(['uid'=>$id]);
    }

    /*
     * 根据地址id查询地址详细
     * */
    public function getAddressById($id)
    {
        $this->autoId = 'id';
        return $this->getRowById($id);
    }

    /*
     * 根据地址id修改地址
     * */
    public function setAddressById($id,$data)
    {
        $this->autoId = 'id';
        return $this->modify($data,$id);
    }

    /*
     * 根据id删除地址
     * */
    public function delAddressById($id)
    {
        $this->autoId = 'id';
        $data['is_invalid'] = 0;
        return $this->modify($data,$id);
    }

    /*
     * 增加地址
     * */
    public function addAdd($data)
    {
        return $this->add($data);
    }
}